/*********************\
* Author:Dzlua
* QQ:505544956
* Time:2017/04/15
\**********************/
#include "LuaText.h"

#define CObjPtr ((CTextUI*)m_cobj)

namespace DuiLib {

int LuaText::EstimateSize(LuaState *L)
{
    LuaStack args(L);
    SIZE szAvailable = LuaHelperNS::GetSize(args[2]);
    SIZE sz = CObjPtr->EstimateSize(szAvailable);
    LuaHelperNS::PushSize(L, sz);
    return 1;
}

int LuaText::GetLinkContent(LuaState *L)
{
    LuaStack args(L);
    if (args[2].IsInteger()) {
        SDTString str = CObjPtr->GetLinkContent(args[2].GetInteger())->GetData();
        LuaHelperNS::PushTString(L, str);
    }
    L->PushNil();
    return 1;
}

SDLUA_BEGIN_REGISTER(LuaText, Text, Label)
    SDLUA_REGISTER_FUN_LUA(LuaText, GetLinkContent, GetLinkContent)
    SDLUA_REGISTER_FUN_LUA(LuaText, EstimateSize, EstimateSize)
SDLUA_END_REGISTER

SDLUA_BEGIN_UNREGISTER(LuaText, Text)
SDLUA_END_UNREGISTER(Text)

}

#undef CObjPtr